<?php if (count($this->entries)): ?>
<?php

    /*
     * komplette taxonomy einlesen
     */
     $this->import('Database');
     $taxLabels = $this->Database->prepare("select * from tl_taxonomy")
                                 ->execute();
     while($taxLabels->next())
    {
       $taxLabelssum[$taxLabels->id] = array
       (
           'name'           => $taxLabels->name,
           'name_en'        => $taxLabels->name_en,
           'alias'          => $taxLabels->alias,
           'tennzeichen'    => $taxLabels->trennzeichen,
       );
    }

    /*
     *  taxonomy labelgenerator
     */
    function getTaxLabel($taxid,$taxArray)
    {
        if($GLOBALS['TL_LANGUAGE'] != 'de')
        {
            $taxLabel = $taxArray[$taxid]['name_'.$GLOBALS['TL_LANGUAGE'].''];
        }
        else
        {
            $taxLabel = $taxArray[$taxid]['name'];
        }
        return $taxLabel;
    }
    /*
     * tabellenzeile generieren
     */
    function generateRow($part,$count,$taxArray)
    {
        foreach ($part as $item)
        {
            //parentname aus taxonomayarray auslesen
            $parentName         = getTaxLabel($item['ref'][0]['pid'],$taxArray);
            $parentTrennzeichen = $taxArray[$item['ref'][0]['pid']]['tennzeichen']." ";
            //namens array
            $i=0;
            $names = Array();
            foreach (explode(',',$item['raw']) as $itemnode)
            {
                $names[] = ucfirst(strtolower(getTaxLabel($item['ref'][$i]['id'],$taxArray)));
                $i++;
            }
            // tabellen reihe generieren
            $row[] = '<tr class="valuerow">
						<td class="label ' .$class. '">'.$parentName.'</td>
						<td class="value ' .$class. '">'.implode($parentTrennzeichen,$names).'</td>
					</tr>';
        }
        return implode($row);
    }
    function getIcons($object)
    {
        foreach (explode(',',$object) as $item)
        {
            //icon 1
            if (($item == '211') and $icon1 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_1_web.jpg"/>';
                $icon1 = true;
            }
            //icon 2
            if (($item == '199' or $item == '201' or $item == '202' or $item == '206') and $icon2 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_2_web.jpg"/>';
                $icon2 = true;
            }
            //icon 3
            if (($item == '209') and $icon3 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_3_web.jpg"/>';
                $icon3 = true;
            }
            //icon 4
            if (($item == '203') and $icon4 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_4_web.jpg"/>';
                $icon4 = true;
            }
            //icon 5
            if (($item == '213') and $icon5 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_5_web.jpg"/>';
                $icon5 = true;
            }
            //icon 7
            if (($item == '205')and $icon7 != true)
            {
                $icon[] = '<img src="tl_files/solana/theme/img/icons/Icon_7_web.jpg"/>';
                $icon7 = true;
            }
        }
        if (count($icon) > 0)
        {
            return implode($icon);
        }
        else
        {
            return $icon;
        }
    }
?>

<div class="layout_full">
<?php foreach ($this->entries as $entry): ?>

<div class="item<?php echo $entry['class'] ? ' '.$entry['class'] : ''; ?>">

    <?php if ($entry['data']['image']['raw']) :?>
            <div class="item_image">
                <?php echo $entry['data']['image']['value']; ?>
            </div>
    <? else: ?>
            <div class="item_image">
             <?php echo $this->generateImage(
               $this->getimage(
                    'tl_files/solana/sortenfinder/produktbilder/solana_logo.png',
                    200,
                    130,
                    'proportional'
                ),
                'Solana'
            );
            ?>
            </div>
    <?php endif; ?>

    <?php if ($entry['data']['name_de']['raw']) :?>
        <h1>
            <?php echo $entry['data']['name_de']['value']; ?>
        </h1>
    <?php endif; ?>

    <div class="iconwrapper">
        <?php echo getIcons($entry['data']['verwertungsrichtung']['raw']); ?>
    </div>
        <div class="createpdf">
            <a href="{{env::request}}?pdf=create&id=<?php echo $this->entries[0][id]; ?>">PDF herunterladen</a>
        </div>

    <?php if($GLOBALS['TL_LANGUAGE']=='de') :?>
        <?php if ($entry['data']['description_de']['raw']) :?>
            <div class="item_desc">
                <?php echo $entry['data']['description_de']['value']; ?>
            </div>
        <?php endif; ?>
    <?php else :?>
        <?php if ($entry['data']['description_en']['raw']) :?>
            <div class="item_desc">
                <?php echo $entry['data']['description_en']['value']; ?>
            </div>
        <?php endif; ?>
    <?php endif; ?>

    <!-- tabelle -->
    <? /*
       * import varhandling
       */
        require_once('templates/solana_de/varhandling_catalog_detail.php');
    ?>
    <div class="data">
        <table>
            <tr>
                <td>
                    <table>
                        <tr>
                            <td class="headline" colspan="2"><h2><?php echo getTaxLabel(29,$taxLabelssum); ?></h2></td>
                        </tr>
                        <?php echo $pflanze; ?>
                    </table>
                </td>
                <td>
                    <table>
                        <tr>
                            <td class="headline" colspan="2"><h2><?php echo getTaxLabel(28,$taxLabelssum); ?></h2></td>
                        </tr>
                        <?php echo $knolle; ?>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table>
                        <tr>
                            <td class="headline" colspan="2"><h2><?php echo getTaxLabel(27,$taxLabelssum); ?></h2></td>
                        </tr>
                        <?php echo $resistanz; ?>
                    </table>
                </td>
                <td>
                    <table>
                        <tr>
                            <td class="headline" colspan="2"><h2><?php echo getTaxLabel(30,$taxLabelssum); ?></h2></td>
                        </tr>
                        <?php echo $ertrag; ?>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <!-- /Tabelle->
</div>
<?php endforeach; ?>
</div>

<?php else: ?>

<?php endif; ?>